package com.unionpay.upyzt.model;

import com.unionpay.upyzt.exception.UpyztException;
import com.unionpay.upyzt.net.APIResource;
import com.unionpay.upyzt.net.RequestOptions;
import com.unionpay.upyzt.resp.BalanceAcctDeleteResp;
import com.unionpay.upyzt.resp.BalanceAcctListResp;
import com.unionpay.upyzt.resp.BalanceAcctResp;
import com.unionpay.upyzt.resp.BalanceAcctStoreResp;
import lombok.experimental.Accessors;

import java.util.Map;

@Accessors(chain = true)
public class BalanceAcct extends APIResource {

    /**
     * 新增电子账簿
     *
     * @param params 请求参数
     * @return 返回参数
     * @throws UpyztException 异常
     */
    public static BalanceAcctStoreResp create(Map<String, Object> params) throws UpyztException {
        return create(params, null);
    }

    /**
     * 新增电子账簿
     *
     * @param params  请求参数
     * @param options 参数选项
     * @return 返回参数
     * @throws UpyztException 异常
     */
    public static BalanceAcctStoreResp create(Map<String, Object> params, RequestOptions options) throws UpyztException {
        return APIResource.request(RequestMethod.POST, classURL(BalanceAcct.class), params, BalanceAcctStoreResp.class, options);
    }

    /**
     * 电子账簿查询（电子账簿ID）
     *
     * @param id 电子账簿ID
     * @return 返回参数
     * @throws UpyztException 异常
     */
    public static BalanceAcctResp retrieveById(String id) throws UpyztException {
        return retrieveById(id, null);
    }

    /**
     * 电子账簿查询（电子账簿ID）
     *
     * @param id      电子账簿ID
     * @param options 参数选项
     * @return 返回参数
     * @throws UpyztException 异常
     */
    public static BalanceAcctResp retrieveById(String id, RequestOptions options) throws UpyztException {
        return APIResource.request(RequestMethod.GET, instanceURL(BalanceAcct.class, id), null, BalanceAcctResp.class, options);
    }

    /**
     * 电子账簿查询（用户ID）
     *
     * @param params 请求参数
     * @return 返回参数
     * @throws UpyztException 异常
     */
    public static BalanceAcctListResp retrieveByUserId(Map<String, Object> params) throws UpyztException {
        return retrieveByUserId(params, null);
    }

    /**
     * 电子账簿查询（用户ID）
     *
     * @param params  请求参数
     * @param options 参数选项
     * @return 返回参数
     * @throws UpyztException 异常
     */
    public static BalanceAcctListResp retrieveByUserId(Map<String, Object> params, RequestOptions options) throws UpyztException {
        return APIResource.request(RequestMethod.GET, classURL(BalanceAcct.class), params, BalanceAcctListResp.class, options);
    }


    /**
     * 注销电子账簿
     *
     * @param id 电子账簿ID
     * @return 返回参数
     * @throws UpyztException 异常
     */
    public static BalanceAcctDeleteResp removeById(String id) throws UpyztException {
        return removeById(id, null);
    }

    /**
     * 注销电子账簿
     *
     * @param id      电子账簿ID
     * @param options 参数选项
     * @return 返回参数
     * @throws UpyztException 异常
     */
    public static BalanceAcctDeleteResp removeById(String id, RequestOptions options) throws UpyztException {
        return APIResource.request(RequestMethod.DELETE, instanceURL(BalanceAcct.class, id), null, BalanceAcctDeleteResp.class, options);
    }

}
